#pragma once

#include <string>
#include <iostream>
#include <WinSock.h>
#include <windows.h>

class Local_connection {
public:
	Local_connection(void);
	~Local_connection(void);

	bool create_connection(unsigned int port);
	bool close_connection();
	bool send_message(std::string message, int &error_code);
	std::string receive_message(bool block, int &error_code);

	static int get_code_error_no_data_received();
	static int get_code_error_server_disconnect();
	static int get_code_success();

private:
	unsigned int m_port;

	WSADATA m_wsa_data;
	SOCKET m_connection_socket;


	static const int K_ERROR_NO_DATA_RECEIVED;
	static const int K_ERROR_SERVER_DISCONNECT;
	static const int K_SUCCESS;

	static const int K_BUFFER_SIZE;

	void set_blocking();
	void set_non_blocking();
};
